/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entidad;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author pc
 */
@Entity
@Table(name = "seatshowtime")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Seatshowtime.findAll", query = "SELECT s FROM Seatshowtime s"),
    @NamedQuery(name = "Seatshowtime.findByShowtimeID", query = "SELECT s FROM Seatshowtime s WHERE s.seatshowtimePK.showtimeID = :showtimeID"),
    @NamedQuery(name = "Seatshowtime.findByCinemaID", query = "SELECT s FROM Seatshowtime s WHERE s.seatshowtimePK.cinemaID = :cinemaID"),
    @NamedQuery(name = "Seatshowtime.findBySeatID", query = "SELECT s FROM Seatshowtime s WHERE s.seatshowtimePK.seatID = :seatID"),
    @NamedQuery(name = "Seatshowtime.findByStatus", query = "SELECT s FROM Seatshowtime s WHERE s.status = :status")})
public class Seatshowtime implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected SeatshowtimePK seatshowtimePK;
    @Column(name = "status")
    private Integer status;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "seatshowtime")
    private List<Ticket> ticketList;
    @JoinColumn(name = "showtimeID", referencedColumnName = "showtimeID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Showtime showtime;
    @JoinColumns({
        @JoinColumn(name = "cinemaID", referencedColumnName = "cinemaID", insertable = false, updatable = false),
        @JoinColumn(name = "seatID", referencedColumnName = "seatID", insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private Seatcinema seatcinema;

    public Seatshowtime() {
    }

    public Seatshowtime(SeatshowtimePK seatshowtimePK) {
        this.seatshowtimePK = seatshowtimePK;
    }

    public Seatshowtime(int showtimeID, int cinemaID, int seatID) {
        this.seatshowtimePK = new SeatshowtimePK(showtimeID, cinemaID, seatID);
    }

    public SeatshowtimePK getSeatshowtimePK() {
        return seatshowtimePK;
    }

    public void setSeatshowtimePK(SeatshowtimePK seatshowtimePK) {
        this.seatshowtimePK = seatshowtimePK;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    @XmlTransient
    public List<Ticket> getTicketList() {
        return ticketList;
    }

    public void setTicketList(List<Ticket> ticketList) {
        this.ticketList = ticketList;
    }

    public Showtime getShowtime() {
        return showtime;
    }

    public void setShowtime(Showtime showtime) {
        this.showtime = showtime;
    }

    public Seatcinema getSeatcinema() {
        return seatcinema;
    }

    public void setSeatcinema(Seatcinema seatcinema) {
        this.seatcinema = seatcinema;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (seatshowtimePK != null ? seatshowtimePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Seatshowtime)) {
            return false;
        }
        Seatshowtime other = (Seatshowtime) object;
        if ((this.seatshowtimePK == null && other.seatshowtimePK != null) || (this.seatshowtimePK != null && !this.seatshowtimePK.equals(other.seatshowtimePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entidad.Seatshowtime[ seatshowtimePK=" + seatshowtimePK + " ]";
    }
    
}
